package com.example.easeimpro.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.example.easeimpro.BaseApplication;

public class SpUtils {
    public static final String IS_NEW_INVITE = "is_new_invite";//新的邀请key
    //保存 读取工具类
    private static SpUtils Instance = new SpUtils();
    private static SharedPreferences mSp;

    private SpUtils(){

    }
    public static SpUtils getInstance( ){
     if(mSp == null){
         mSp = BaseApplication.getGlobalApplication().getSharedPreferences("im", Context.MODE_PRIVATE);
     }

        return Instance ;
    }


    public  void  save(String key, Object value){
        if(value instanceof String){
            mSp.edit().putString(key, (String) value).apply();
        }else if(value instanceof Boolean){
            mSp.edit().putBoolean(key, (Boolean) value).apply();
        }else if(value instanceof Integer){
            mSp.edit().putInt(key, (Integer) value).apply();
        }
    }

    public  String getString(String key, String defValue){
        return mSp.getString(key,defValue);
    }
    public  boolean getBoolean(String key, boolean defValue){
        return mSp.getBoolean(key,defValue);
    }
    public  int getInt(String key, int defValue){
        return mSp.getInt(key,defValue);
    }

    public  void setFriendBox(boolean isBox){
        mSp.edit().putBoolean("friend",isBox).apply();
    }
    public  boolean getFriendBox(){
       return mSp.getBoolean("friend",false);
    }
}
